<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta charset="utf-8">
    <title>约课</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="bookmark" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/layui/css/layui.css" media="all">
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/layui/layui.js"
            charset="utf-8"></script>
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/jquery/jquery.js"></script>
    <script type="application/javascript"
            src="${pageContext.request.contextPath}/private/js/loading/ajaxloading.js"></script>
</head>
<body>
<fieldset class="layui-elem-field">
    <legend>查询条件</legend>
    <form id="form1" class="layui-form" action="">
        <table width="96%" align="center">
            <tr height="23">
                <td align="center">会员手机:</td>
                <td>
                    <input type="hidden" id="validflag" name="validflag" value="1" >
                    <input id="telephone" name="telephone" class="layui-input" type="text" placeholder="请输入会员手机号"
                           autocomplete="off"
                           lay-verify="telephone">
                </td>
                <td align="center">用户姓名:</td>
                <td>
                    <input id="username" name="username" class="layui-input" type="text" placeholder="请输用户姓名关键字"
                           autocomplete="off"
                           lay-verify="username">
                </td>
                <td align="center">
                    <button class="layui-btn" lay-submit lay-filter="query">查询</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
        </table>
    </form>
</fieldset>

<fieldset class="layui-elem-field">
    <legend>会员列表</legend>
    <table class="layui-table" lay-filter="gridfilter"
           lay-data="{url:'',page:true, id:'gridresult',height:'330px',defaultToolbar: ['filter']}">
        <thead>
        <tr>
            <th lay-data="{field:'usernid',hide:true}">账号id</th>
            <th lay-data="{field:'openid',align:'center',hide:true}">openid</th>
            <th lay-data="{field:'username',align:'center'}">用户姓名</th>
            <th lay-data="{field:'sex',templet: '#swithsex',align:'center'}">性别</th>
            <th lay-data="{field:'telephone',align:'center'}">联系电话</th>
            <th lay-data="{field:'tiyannums',align:'center'}">体验课时数</th>
            <th lay-data="{field:'restclass',align:'center'}">剩余课时</th>
            <th lay-data="{fixed: 'right',align:'center', toolbar: '#barDemo'}">操作</th>
        </tr>
        </thead>
    </table>

</fieldset>

<fieldset class="layui-elem-field">
    <legend>会员约课历史记录</legend>
    <table class="layui-table" lay-filter="gridfilter_appointment"
           lay-data="{url:'',page:true, id:'gridresult_appointment',height:'330px',width : '1080',defaultToolbar: ['filter']}">
        <thead>
        <tr>
            <th lay-data="{field:'appointmentid',hide:true}">约课ID</th>
            <th lay-data="{field:'userid',align:'center',hide:true}">会员ID</th>
            <th lay-data="{field:'cid',align:'center',hide:true}">上课孩子ID</th>
            <th lay-data="{field:'classid',hide:true}">课程ID</th>
            <th lay-data="{field:'recordid',hide:true}">开班ID</th>
            <th lay-data="{field:'coachid',hide:true}">授课教练ID</th>
            <th lay-data="{field:'atime',align:'center',width:'200'}">约课时间</th>
            <th lay-data="{field:'classname',align:'center',width:'150'}">课程名称</th>
            <th lay-data="{field:'coachname',align:'center',width:'150'}">授课教练</th>
            <th lay-data="{field:'cname',align:'center',width:'150'}">上课孩子姓名</th>
            <th lay-data="{field:'starttime',align:'center',width:'200'}">开课日期</th>
            <th lay-data="{field:'begintime',align:'center',width:'200'}">上课时间</th>
            <th lay-data="{field:'endtime',align:'center',width:'200'}">下课时间</th>
            <th lay-data="{field:'address',align:'center',width:'400'}">上课地点</th>

            <th lay-data="{field:'isdy',align:'center',hide:true}">预约类型编码</th>
            <th lay-data="{field:'isdy_str',align:'center',width:'200'}">预约类型</th>
            <th lay-data="{field:'appuserid',hide:true}">预约人ID</th>
            <th lay-data="{field:'appusername',align:'center',width:'150'}">预约人</th>
            <th lay-data="{field:'status',hide:true}">课程完成情况编码</th>
            <th lay-data="{field:'status_str',align:'center',width:'200'}">课程完成情况</th>
            <th lay-data="{field:'consumes',align:'center',width:'100'}">消耗总课时数</th>
            <th lay-data="{field:'consumest',align:'center',width:'100'}">消耗体验课时数</th>
            <th lay-data="{field:'operationid',hide:true}">经办人ID</th>
            <th lay-data="{field:'operationname',align:'center',width:'150'}">操作人</th>
            <th lay-data="{field:'operationtime',align:'center',width:'200'}">操作时间</th>
            <th lay-data="{fixed: 'right',align:'center', toolbar: '#barDemo2',width:'200'}">操作</th>
        </tr>
        </thead>
    </table>

</fieldset>
</body>
<script id="swithsex" type="text/html">
    <input type="checkbox" name="sex" value="true" lay-skin="switch" lay-text="男|女" disabled {{
           d.sex=='1'?'checked' : '' }}>
</script>
<script id="barDemo" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="edit">约课</a>
</script>
<script id="barDemo2" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="edit">已约课编辑</a>
</script>
<script type="application/javascript">
    layui.use(['form', 'table'], function () {
        var form = layui.form;
        var select_userid;
        var query_data = {};
        //数据表格模块
        var table = layui.table;
        table.reload('gridresult', {
            url: '${pageContext.request.contextPath}/eyas/userinfo/queryUserInfo'
            , where: {validflag:'1'} //设定异步数据接口的额外参数
            , page: {
                curr: 1
            },
            method:'get'
        });
        //监听提交
        form.on('submit(query)', function (data) {
            query_data = data.field;
            table.reload('gridresult', {
                url: '${pageContext.request.contextPath}/eyas/userinfo/queryUserInfo'
                , where: data.field //设定异步数据接口的额外参数
                , page: {
                    curr: 1
                },
                method:'get'
            });
            return false;
        });
        //监听行工具事件
        table.on('tool(gridfilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                var win_1 = layer.open({
                    type: 2,
                    title: '会员约课',
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['100%', '100%'],
                    content: '${pageContext.request.contextPath}/eyas/appointmentinfo/edit?userid='+data.userid,
                    end:function() {
                        table.reload('gridresult', {
                            url: '${pageContext.request.contextPath}/eyas/userinfo/queryUserInfo'
                            , where: query_data //设定异步数据接口的额外参数
                            , page: {
                                curr: 1
                            },
                            method:'get'
                        });
                        if(select_userid) {
                            table.reload('gridresult_appointment', {
                                url: '${pageContext.request.contextPath}/eyas/appointmentinfo/queryAppointmentInfo'
                                , where: {userid:select_userid} //设定异步数据接口的额外参数
                                , page: {
                                    curr: 1
                                },
                                method:'get'
                            });
                        }

                    }
                });
                layer.full(win_1);
            }
        });
        //监听行单击事件（单击事件为：rowDouble）
        table.on('row(gridfilter)', function(obj){
            var data = obj.data;
            select_userid = data.userid;
            table.reload('gridresult_appointment', {
                url: '${pageContext.request.contextPath}/eyas/appointmentinfo/queryAppointmentInfo'
                , where: {userid:data.userid} //设定异步数据接口的额外参数
                , page: {
                    curr: 1
                },
                method:'get'
            });
        });
        //监听行工具事件
        table.on('tool(gridfilter_appointment)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                if(data.status&&data.status!='1') {
                    layer.msg("只能编辑[未签到]的约课信息");
                    return;
                }
                var win_1 = layer.open({
                    type: 2,
                    title: '课程签到',
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['100%', '100%'],
                    content: '${pageContext.request.contextPath}/eyas/appointmentinfo/edit2?appointmentid='+data.appointmentid,
                    end:function() {
                        table.reload('gridresult', {
                            url: '${pageContext.request.contextPath}/eyas/userinfo/queryUserInfo'
                            , where: query_data //设定异步数据接口的额外参数
                            , page: {
                                curr: 1
                            },
                            method:'get'
                        });
                        if(select_userid) {
                            table.reload('gridresult_appointment', {
                                url: '${pageContext.request.contextPath}/eyas/appointmentinfo/queryAppointmentInfo'
                                , where: {userid:select_userid} //设定异步数据接口的额外参数
                                , page: {
                                    curr: 1
                                },
                                method:'get'
                            });
                        }

                    }
                });
                layer.full(win_1);
            }
        });
    });
</script>
</html>
